Skip to content

[codex] Respect zero probability mutation#15

Open
alerodriargui wants to merge 1 commit into
SantanderAI:mainfrom
alerodriargui:codex/fix-zero-mutation-prob
Open

[codex] Respect zero probability mutation#15
alerodriargui wants to merge 1 commit into
SantanderAI:mainfrom
alerodriargui:codex/fix-zero-mutation-prob

Conversation

@alerodriargui

Copy link
Copy Markdown

Description

Fixes the probability mutation defaulting logic so mutation_prob=0 is respected instead of being treated as omitted.

Previously, Chromosome.mutate() used a truthiness check, so passing 0 fell back to the default 1 / len(self.data) probability and could still mutate genes. The new check defaults only when mutation_prob is None.

Adds a regression test covering the zero-probability case.

Related issue

Closes #14

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Documentation only

Checklist

  • I have signed the CLA (the CLA Assistant bot will prompt external contributors)
  • My commit messages follow Conventional Commits
  • ruff check . and black --check . pass
  • mypy genetic_algorithm passes
  • pytest passes
  • The engine remains dependency-free (standard library only)
  • I have added/updated tests where relevant
  • I have updated documentation where relevant
  • No secrets, API keys, internal URLs, or proprietary content are included

@alerodriargui alerodriargui requested review from a team as code owners July 3, 2026 15:29
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mutation_prob=0 is ignored by probability_mutation

1 participant